package com.ruoyi.utils;

import com.ruoyi.domain.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author chenjc
 * @since 2020/11/25 17:43
 */
public class SelectHelpUtil {

    //师傅-客户关联下拉信息
    public static List<Map> toListMap(List<HhWorker> dataList) {

        List<Map> resultList = new ArrayList<>();

        for (HhWorker worker : dataList) {
            List<Map> userList = new ArrayList<>();
            for (HhUser hhUser : worker.getHhUsers()) {
                Map<String, Object> userMap = new HashMap<>();
                userMap.put("id", hhUser.getUserId());
                userMap.put("name", hhUser.getUserName());
                userList.add(userMap);
            }

            Map<String, Object> workerMap = new HashMap<>();
            workerMap.put("id", worker.getWorkerId());
            workerMap.put("name", worker.getWorkerName());
            workerMap.put("users", userList);

            resultList.add(workerMap);
        }

        return resultList;
    }

    //用户下拉信息
    public static List<Map> getNameUser(List<HhUser> dataList) {

        List<Map> resultList = new ArrayList<>();

        Map<String, Object> selectMap = null;
        for (HhUser hhUser : dataList) {
            selectMap = new HashMap<>();
            selectMap.put("id", hhUser.getUserId());
            selectMap.put("name", hhUser.getUserName());
            resultList.add(selectMap);
        }

        return resultList;
    }

    //分类下拉信息
    public static List<Map> getNameType(List<HhType> dataList) {

        List<Map> resultList = new ArrayList<>();

        Map<String, Object> selectMap = null;
        for (HhType type : dataList) {
            selectMap = new HashMap<>();
            selectMap.put("id", type.getTypeId());
            selectMap.put("name", type.getTypeName());
            resultList.add(selectMap);
        }

        return resultList;
    }

    //品牌下拉信息
    public static List<Map> getNameBrand(List<HhBrand> dataList) {

        List<Map> resultList = new ArrayList<>();

        Map<String, Object> selectMap = null;
        for (HhBrand brand : dataList) {
            selectMap = new HashMap<>();
            selectMap.put("id", brand.getBrandId());
            selectMap.put("name", brand.getBrandName());
            resultList.add(selectMap);
        }

        return resultList;
    }

    //规格下拉信息
    public static List<Map> getNameSize(List<HhSize> dataList) {

        List<Map> resultList = new ArrayList<>();

        Map<String, Object> selectMap = null;
        for (HhSize size : dataList) {
            selectMap = new HashMap<>();
            selectMap.put("id", size.getSizeId());
            selectMap.put("name", size.getSizeName());
            resultList.add(selectMap);
        }

        return resultList;
    }

}
